Skip to content

Conversation

@mklement0
Copy link
Contributor

As originally discussed in PowerShell/PowerShell#6576



It's probably worth creating a new conceptual help topic titled `about_Collection_Operators` to describe these new operators.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: all of the comparison operators work with collections e.g. "a", "b", "c", "d" -match "[bc]" will return "b", "c".

Copy link
Contributor Author

@mklement0 mklement0 Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrucePay: Good point, but the new operators are not about also working on collections; their whole purpose is to operate on collections; additionally, their purpose is open-ended, given that the meat of the behavior is in the script blocks passed.

So my suggestion is to have the new topic mention the collection-processing capabilities of comparison operators such as -eq and -match and link to about_comparison_operators.

@iSazonov
Copy link
Contributor

iSazonov commented May 3, 2018

@mklement0 I believe it makes sense to add a description of exception behavior in the operators.

@mklement0
Copy link
Contributor Author

@iSazonov: Thanks; I've added a note re error handling, operator precedence, and return, break, continue semantics: in short: it all should work the same as with the .ForEach() / .Where() methods.

@joeyaiello
Copy link
Contributor

Currently, we on the @PowerShell/powershell-committee think that introducing what amounts to a third (or fourth) reference to "foreach" (foreach keyword, ForEach-Object, and .ForEach()) and a second/third reference to "where" is going to confuse existing users who are already struggling with deciding which to choose.

Instead, we think it's probably a good idea to come up with some ScriptAnalyzer rules and accompanying documentation that explain why it might not be a good idea to use | ForEach-Object or | Where-Object in non-interactive scenarios. Based on the reception of these rules, the hit rate of that documentation, etc., we can make a more informed decision about whether this is necessary.

@joeyaiello joeyaiello closed this Apr 1, 2019
@joeyaiello
Copy link
Contributor

Thanks for writing this, though @mklement0. Very through provoking, and we're not opposed to ever doing it, but I am going to merge this one into the Rejected state now for posterity.

@joeyaiello joeyaiello reopened this Apr 1, 2019
@joeyaiello joeyaiello merged commit 191e91a into PowerShell:master Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants